<script setup lang="ts">
import { ref } from 'vue'
import type { Entity } from '../base'

const s = ref<string | null>(null)

function filter(lst: Entity[]): Entity[] {
  if (!s.value) {
    return lst
  }
  let ss = s.value.trim()
  if (!ss || ss.length === 0) {
    return lst
  }
  ss = ss.toLowerCase()
  return lst.filter((e) => e.id.toLowerCase().indexOf(ss) >= 0)
}

defineExpose({ filter })
</script>
<template>
  <div class="row">
    <div class="txt-box col-2em">id</div>
    <input class="input" v-model="s" placeholder="模糊匹配" />
  </div>
</template>
